﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using log4net;
namespace Register.Command
{
    /// <summary> 
    /// FileName: logNote.cs    
    /// CLRVersion: 4.0.30319.269    
    /// Author: DoubleZ    
    /// Corporation:     
    /// Description:     
    /// DateTime: 2012/6/23 17:58:51    
    /// </summary>
  public static class LogRecordHelper
    {
      /// <summary>
      ///该方法根据传递的日志权限和日志信息，将日志对象插入到数据库中
      ///权限由高到低:OFF > FATAL > ERROR > WARN > INFO > DEBUG > ALL
      /// </summary>
        /// <param name="_logLevel">权限由高到低:OFF > FATAL > ERROR > WARN > INFO > DEBUG > ALL</param>
      /// <param name="_logMessage"></param>
      /// <returns></returns>
        public static int LogNote(string _logLevel, string _logMessage)
        {
            //获取当前调用该方法的类,并根据该类创建日志对象
            ILog log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
            switch (_logLevel)
            {

                case "FATAL": log.Fatal(_logMessage); return 1;
                case "ERROR": log.Error(_logMessage); return 2;
                case "WARN": log.Warn(_logMessage); return 3;
                case "INFO": log.Info(_logMessage); return 4;
                case "DEBUG": log.Debug(_logMessage); return 5;
                default: return -1;
            }

        }
    }
}
